package test;

import com.lhx.wechat.entity.menu.Button;
import com.lhx.wechat.entity.menu.ButtonTypeConstants;
import com.lhx.wechat.entity.menu.CommonButton;
import com.lhx.wechat.entity.menu.ComplexButton;
import com.lhx.wechat.entity.menu.Menu;
import com.lhx.wechat.entity.menu.ViewButton;
import com.lhx.wechat.utils.WechatCreateMenuUtil;

/**
 * 创建菜单
 * 
 * @author ZhangBo
 *
 */
public class CreateMenu {
	
	private static String APP_ID = "wx6e585422454e77ba";

	public static void main(String[] args) {
		WechatCreateMenuUtil.createMenu(buildTestMenu(), APP_ID);
		System.out.println("--->>>  ");
	}

	// 生成菜单
	private static Menu buildTestMenu() {
		String insurance = "http://www.longhongxing.com";
		ViewButton btn11 = new ViewButton();
		btn11.setName("首页");
		btn11.setType(ButtonTypeConstants.VIEW);//
		btn11.setUrl(insurance);
		
		CommonButton btn12 = new CommonButton();
		btn12.setKey("测试");
		btn12.setName("扫码推事件");
		btn12.setType(ButtonTypeConstants.SCANCODE_PUSH);
		
		CommonButton btn13 = new CommonButton();
		btn13.setKey("测试");
		btn13.setName("扫码推事件弹框");
		btn13.setType(ButtonTypeConstants.SCANCODE_WAITMSG);
		
		CommonButton btn14 = new CommonButton();
		btn14.setKey("测试");
		btn14.setName("弹出系统拍照发图");
		btn14.setType(ButtonTypeConstants.PIC_SYSPHOTO);
		
		ComplexButton mainBtn1 = new ComplexButton();
		mainBtn1.setName("联系我们");
		mainBtn1.setSub_button(new Button[] { btn11, btn12, btn13, btn14});
		
		// -------
		CommonButton btn21 = new CommonButton();
		btn21.setKey("online-service");
		btn21.setName("在线客服");
		btn21.setType(ButtonTypeConstants.CLICK);

		ViewButton btn22 = new ViewButton();
		btn22.setName("关于我们");
		btn22.setType(ButtonTypeConstants.VIEW);
		btn22.setUrl(insurance);
		
		CommonButton btn23 = new CommonButton();
		btn23.setName("弹出地理位置选择器");
		btn23.setType(ButtonTypeConstants.LOCATION_SELECT);

		ComplexButton mainBtn2 = new ComplexButton();
		mainBtn2.setName("联系我们");
		mainBtn2.setSub_button(new Button[] { btn21, btn22, btn23});

		Menu menu = new Menu();
		menu.setButton(new Button[] { mainBtn1, mainBtn2 });

		return menu;
	}

}
